package com.gitee.ykr.rpcclient;

import com.gitee.ykr.lightweight.rpc.annotation.EnableNettyRpc;
import com.gitee.ykr.lightweight.rpc.monitor.trace.MonitorMessage;
import com.gitee.ykr.rpcclient.service.Hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author YKR
 * @Describe
 * @date 2021/9/6
 */
@SpringBootApplication
@RestController
@EnableNettyRpc(basePackages = "com.gitee.ykr")
public class RpcClientApplication {

    public static void main(String[] args) {
        SpringApplication.run( RpcClientApplication.class, args );
    }


    @Autowired
    Hello hello;

    @GetMapping("/test")
    public String test() throws Exception {

//        IGreeting invoker = (IGreeting) Invoker.invoke( IGreeting.class );
//        Object result = invoker.sayHello( "sww" );
        return hello.say();
    }

    @PostMapping("/postmsg")
    public void post(@RequestBody MonitorMessage message) {
        //System.out.println(JSON.toJSONString(message));
    }
}
